xm: Fix xm vcpu-pin to complain for CPU numbers out of range.
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 20 Feb 2008 17:42:12 +0000 (17:42 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 20 Feb 2008 17:42:12 +0000 (17:42 +0000)
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
tools/python/xen/lowlevel/xc/xc.c

index 305138bd70559dbecb9c0df6f2a3d8cb2d58d015..a52b0b036f15fbc5735eaa6d034fa917f52fa7e1 100644 (file)
@@ -227,7 +227,16 @@ static PyObject *pyxc_vcpu_setaffinity(XcObject *self,
     {
         cpumap = 0ULL;
         for ( i = 0; i < PyList_Size(cpulist); i++ ) 
-            cpumap |= (uint64_t)1 << PyInt_AsLong(PyList_GetItem(cpulist, i));
+        {
+            long cpu = PyInt_AsLong(PyList_GetItem(cpulist, i));
+            if ( cpu >= 64 )
+            {
+                errno = EINVAL;
+                PyErr_SetFromErrno(xc_error_obj);
+                return NULL;
+            }
+            cpumap |= (uint64_t)1 << cpu;
+        }
     }
   
     if ( xc_vcpu_setaffinity(self->xc_handle, dom, vcpu, cpumap) != 0 )